package org.soc.timesheet.custom.domain.filters;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.soc.timesheet.domain.Users;
import org.springframework.data.jpa.domain.Specification;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

@JsonAutoDetect(fieldVisibility=Visibility.ANY)
@JsonInclude(Include.NON_NULL)
public class UserFilter implements Specification<Users> {

	private String login;
	@Override
	public Predicate toPredicate(Root<Users> root, CriteriaQuery<?> query,
			CriteriaBuilder cb) {
		Expression<String> expLogin = root.<String>get("login");
		return cb.like(expLogin, login);
	}
	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}

}
